package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "页面组件", model = "页面组件")
@Entity
@Table(name = "bs_page_component")
@Comment("页面组件表")
public class PageComponent extends AbstractEntity {

    @Comment("布局ID")
    @FormField(title = "布局ID", sortNum = "1", required = true)
    private Long layoutId;

    @Comment("组件名称")
    @SearchItem(name = "name", key = "name", label = "组件名称")
    @FormField(title = "组件名称", sortNum = "2", grid = true, required = true)
    @Column(length = 100, nullable = false)
    private String name;

    @Comment("组件类型")
    @FormField(title = "组件类型", sortNum = "3", grid = true, type = InputType.select, required = true)
    @Column(length = 50, nullable = false)
    private String componentType; // BANNER-轮播图, PRODUCT_LIST-商品列表, NAVIGATION-导航, SEARCH-搜索框, CATEGORY-分类, ADVERTISEMENT-广告

    @Comment("组件标题")
    @FormField(title = "组件标题", sortNum = "4", grid = true)
    @Column(length = 200)
    private String title;

    @Comment("组件副标题")
    @FormField(title = "组件副标题", sortNum = "5")
    @Column(length = 500)
    private String subtitle;

    @Comment("组件位置")
    @FormField(title = "组件位置", sortNum = "6", grid = true, type = InputType.el_input_number, required = true)
    private Integer position;

    @Comment("组件宽度")
    @FormField(title = "组件宽度", sortNum = "7", grid = true, type = InputType.el_input_number)
    private Integer width;

    @Comment("组件高度")
    @FormField(title = "组件高度", sortNum = "8", grid = true, type = InputType.el_input_number)
    private Integer height;

    @Comment("背景颜色")
    @FormField(title = "背景颜色", sortNum = "9", type = InputType.text)
    @Column(length = 20)
    private String backgroundColor;

    @Comment("背景图片")
    @FormField(title = "背景图片", sortNum = "10", type = InputType.image)
    @Column(length = 500)
    private String backgroundImage;

    @Comment("内边距")
    @FormField(title = "内边距", sortNum = "11")
    @Column(length = 50)
    private String padding;

    @Comment("外边距")
    @FormField(title = "外边距", sortNum = "12")
    @Column(length = 50)
    private String margin;

    @Comment("边框样式")
    @FormField(title = "边框样式", sortNum = "13")
    @Column(length = 100)
    private String border;

    @Comment("圆角")
    @FormField(title = "圆角", sortNum = "14")
    @Column(length = 20)
    private String borderRadius;

    @Comment("阴影")
    @FormField(title = "阴影", sortNum = "15")
    @Column(length = 100)
    private String boxShadow;

    @Comment("是否显示")
    @FormField(title = "是否显示", sortNum = "16", grid = true, type = InputType.select)
    private Boolean visible;

    @Comment("排序")
    @FormField(title = "排序", sortNum = "17", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sort;

    @Comment("组件配置JSON")
    @FormField(title = "组件配置", sortNum = "18", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String config;

    @Comment("数据源类型")
    @FormField(title = "数据源类型", sortNum = "19", grid = true, type = InputType.select)
    @Column(length = 20)
    private String dataSourceType; // STATIC-静态数据, DYNAMIC-动态数据, API-接口数据

    @Comment("数据源配置")
    @FormField(title = "数据源配置", sortNum = "20", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String dataSourceConfig;
} 